/**2016-7-25
MR-Deng
TODO
 * 
 */package cn.broadin.app.hotel.setup;/** * @author  作者 E-mail: * @date 创建时间：2016-7-25 下午3:13:23 * @version 1.0 * @parameter  * @since  * @return  */


import cn.broadin.app.hotel.BaseActivity;
import cn.broadin.app.hotel.LoadActivity;
import cn.broadin.app.hotel.R;
import cn.broadin.app.hotel.app.AppConfig;
import cn.broadin.app.hotel.app.AppContext;
import cn.broadin.app.hotel.util.XToast;
import cn.broadin.app.hotel.util.XUtils;

import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;

import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

/**
 * @author MR-Deng
 *
 */
 
public class PasswordActivity extends BaseActivity{
	private String passwordNum;
	
	private EditText password;
	private Button mImageView;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_init_password);
		
		password = (EditText) this.findViewById(R.id.input_password_num);
		mImageView = (Button) this.findViewById(R.id.auth_button);
		
		
		
		mImageView.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				passwordNum = password.getText().toString();
				AppContext appContext = (AppContext)getApplicationContext();  //获取全局变量app
				String productInfo = appContext.getProductInfo();
				ComponentName comp = null;
				if(TextUtils.isEmpty(passwordNum)){
					XToast.makeText(PasswordActivity.this, "请输入密码", 3000).show();
				} else {
					if(passwordNum.equals(AppConfig.settingPW)) {
						try {
							Intent mIntent = new Intent();
							
							if(productInfo == null || productInfo.equals("")) {  //再获取一次厂家信息
								productInfo = XUtils.getSystemInfo();
							}
							
							if(productInfo.equals("MBX") || productInfo.equals("CNCR")) {  //智诺达和初灵方案系统设置
								 comp = new ComponentName("com.mbx.settingsmbox", "com.mbx.settingsmbox.SettingsMboxActivity");  
							} else if(productInfo.equals("JIUZHOU")) { //九州方案系统设置
								 comp = new ComponentName("com.jzbyapp.jzsettings", "com.jzbyapp.jzsettings.MainActivity");
							} else if(productInfo.equals("Skyworth")) {//创维一体机
								 comp = new ComponentName("com.tianci.setting","com.tianci.setting.TianciSetting");	
							}
							
							else { //默认进入安卓原生系统设置
								 comp = new ComponentName("com.android.settings", "com.android.settings.Settings");
							}
							
							mIntent.setComponent(comp);
							mIntent.setAction("android.intent.action.MAIN");
							mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
							Bundle mbundle = new Bundle(); 
							mbundle.putString("versionCode", AppConfig.versionCode);
							mbundle.putString("versionDate", AppConfig.versionDate);
							mbundle.putString("versionArea", AppConfig.versionArea);
							mIntent.putExtras(mbundle);
							startActivity(mIntent);
							PasswordActivity.this.finish();
						} catch (Exception e) {
							e.printStackTrace();
							XToast.makeText(PasswordActivity.this, "应用启动失败！").show();
						}
					} else {
						password.setText("");
						XToast.makeText(PasswordActivity.this, "密码错误,请重新输入密码", 3000).show();
					}
				}
			}
		});
	}
	
}
